(load "collection.el")

(defun walkthru2 (l el ret)
  (cond ((nullp l)
	 nil)
	((eq (car l) el)
	 ret)
	(t
	 (walkthru2 (cdr l) el (+ 1 ret)))
	))
	 
	   
(defun rem3 (l key keys values retkeys retvalues)
  (cond ((nullp l)
	 (error (format "SequenceableCollection : Could not remove %s ! Exiting..." oldObject)));;FIXME do not error
	((eq (car l) key)
	 (setq keys (append retkeys (cdr keys))))
	(t
	 (rem3 (cdr l) key (append (car keys) retkeys) (append (car values) values)))
	))
	  

(defun SequenceableCollection (name)
  (let* ((*class "SequenceableCollection")
	 (*instance-name name)
	 (*values ())
	 (*super (Collection name))
	 
	 (*dispatch
	  (lambda (msg)
	    (cond

	     ;;p169 ST-80
	     ((eq msg "indexOf:")
	      (lambda (key)
		(walkthru2 *values key 1));;NOTE first index is 1 not 0

	     (t
	      ((*super msg)))
	     )))
	 )
    
    *dispatch))
